package com.lry.sso.common.entity.response;

import com.lry.sso.common.entity.SysError;
import com.lry.sso.common.exception.SysInvocationException;

/**
 *  返回结果处理工具
 *
 * @author 李瑞益
 * @date 2019/10/2
 */
@SuppressWarnings("unchecked")
public class Ret {

    public static <T> ResultData<T> data(T data) {
        return new ResultData<T>(data);
    }

    public static ResultData ok(ResponseInfo info) {
        ResultData result = new ResultData();
        return result;
    }

    public static ResultData ok(int code, String message) {
        return new ResultData(new ResponseInfo(code, message));
    }

    public static ResultData error(SysError errorEntity) {
        return new ResultData(errorEntity);
    }

    public static ResultData error(String code, String message) {
        return new ResultData(new SysError(code,message));
    }

    public static ResultData error(SysInvocationException error) {
        return new ResultData(new SysError(error.getError().getCode(),error.getError().getMessage()));
    }

}